﻿Imports VendasBLL
Class AlterarSenhaCAD
    Public objlogin As New UsuarioBLL

#Region "Metodos"
#Region "Carrega"
    Public Sub carrega()
        If (Not IsNothing(objlogin)) Then
            If (objlogin.Codigo > 0) Then
                tLogin.Text = objlogin.Descricao
            End If
        End If
    End Sub
#End Region
#End Region

#Region "Eventos"
#Region "Load"
    Private Sub AlterarSenhaCAD_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If Not IsNothing(objlogin) Then
            If (objlogin.Codigo > 0) Then
                Me.carrega()
            End If
        End If
    End Sub
#End Region

#Region "TSBGravar_CLick"
    Private Sub TSBGravar_Click(sender As System.Object, e As System.EventArgs) Handles TSBGravar.Click
        Try
            Dim x As Boolean
            If (tSenha.Text.Trim = tNovaSenha.Text.Trim) Then
                x = objlogin.Alterarsenha(tSenha.Text.Trim)
                If x Then
                    MessageBox.Show("Senha alterada!", "Finalização", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Me.Close()
                Else
                    Throw New Exception("A senha não pôde ser alterada!")
                End If
            Else : Throw New Exception("senha e nova senha devem ser as mesmas!")
            End If
           

        Catch ex As Exception
            MessageBox.Show(ex.Message, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub
#End Region

#Region "TSBVoltar"
    Private Sub TSBVoltar_Click(sender As System.Object, e As System.EventArgs) Handles TSBVoltar.Click
        Me.Close()
    End Sub
#End Region
#End Region



End Class